package com.taldh.springframework.beanlifecycle;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;

public class BeanPostProcessorTest implements  BeanPostProcessor {

    /**
     * BeanPostProcessor 的 postProcessBeforeInitialization
     */
    @Override
    public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
        System.out.println("第十一个执行 postProcessBeforeInitialization bean = " );
        System.out.println("第十一个执行 postProcessBeforeInitialization beanName = " + beanName );
        return bean;
    }

    /**
     * 指定 的 initMethod
     */
    public void initMethod() {
        System.out.println("第十三个执行 = initMethod");
    }

    /**
     * BeanPostProcessor 的 postProcessAfterInitialization
     */
    @Override
    public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
        System.out.println("第十四个执行 postProcessAfterInitialization bean = " );
        System.out.println("第十四个执行 postProcessAfterInitialization beanName = " + beanName);
        return bean;
    }

    public void destroyMethod() {
        System.out.println("第三个执行的销毁方法 ");
    }
}
